package com.neusoft.blog.controller;

import com.github.pagehelper.PageInfo;
import com.neusoft.blog.bean.Article;
import com.neusoft.blog.bean.ArticlePo;
import com.neusoft.blog.bean.Echars;
import com.neusoft.blog.bean.RespBean;
import com.neusoft.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/aticle")

public class AticleController {
@Autowired
ArticleService articleService;

    @PostMapping ("/saveAticle")
    public RespBean saveAticle(@RequestBody Article article){

        return  articleService.saveAticle(article);
    }
    @PutMapping("/updeteAticle")
    public  RespBean updeteAticle(@RequestBody Article article){
        return  articleService.updeteAticle(article);
    }
    @GetMapping("/getArticls")
    public PageInfo getArticls ( ArticlePo articlePo){
        return  articleService.getArticls(articlePo);
    }

    @GetMapping("/getArticlsById")
    public  Article getArticlsById(Integer aid){
        return  articleService.getArticlsById(aid);
    }
    @PutMapping("/updeteCount")
    public int updeteCount(Integer count,Integer aid){
        return articleService.updeteCount(count,aid);
    }
    @DeleteMapping("/delArticl/{id}")
    public RespBean delArticl (@PathVariable("id") Integer id){
        return articleService.delArticl(id);
    }
    @DeleteMapping("/multiDel")
    public  RespBean multiDel(Integer[] ids){
        return articleService.multiDel(ids);

    }

    @GetMapping("/echarsByName")
    public List<Echars> echarsByName(){
        return  articleService.echarsByName();
    }
}
